<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>首页--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${basePath!}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${basePath!}/static/css/public.css" media="all" />
</head>
<body class="childrenBody">
	<blockquote class="layui-elem-quote layui-bg-green">
		<div id="nowTime"></div>
	</blockquote>
	<div class="weadmin-body">
		<div id="main" style="width: 100%;height:400px;"></div>
	</div>
    <div class="weadmin-body">
        <div id="index" style="width: 100%;height:400px;"></div>
    </div>
    <script type="text/javascript" src="${basePath!}/static/layui/layui.js"></script>
	<script type="text/javascript" src="${basePath!}/static/js/main.js"></script>
	<script src="${basePath!}/static/js/echarts.min.js"></script>
	<script src="${basePath!}/static/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		// 基于准备好的dom，初始化echarts实例
		var myChart = echarts.init(document.getElementById('main'));
        var ourChart = echarts.init(document.getElementById('index'));
		// 指定图表的配置项和数据
		var labelRight = {
			normal: {
				position: 'right'
			}
		};
		$(function () {
			getData();
			getData2()
		});
		function  getData() {
			$.ajax({
				type: 'get',
				url:  '${basePath!}/custom/countByYear',
				dataType: 'json',
				data: {},
				success: function (data) {
					var data1 = new Array();
					var data2 = new Array();
					var data3 = new Array();
					var data4 = new Array();
					var data5 = new Array();
					var data6 = new Array();
					var data7 = new Array();
					for(var i=0; i < data.length; i++){
						if(data[i].year == 2018) {
							data1.push(data[i].creator);
						}else{
							data3.push(data[i].creator);
						}
						if(data[i].creator == '000001'){
							data5.push(data[i].count)
						}
						if(data[i].creator == 'admin'){
							data6.push(data[i].count)
						}
						if(data[i].creator == 'lijunwu'){
							data7.push(data[i].count)
						}
						data2[i] = data[i].count;
					}
					//alert(JSON.stringify(data));
					for(var i=0;i<data3.length;i++){
						data1.push(data3[i]);
					}
					var myChart = echarts.init(document.getElementById('main'));
					console.log(data5,data6,data7);
					// 指定图表的配置项和数据
					option = {
						tooltip: {
							//trigger: 'axis',
						},
						grid: {
							left: '3%',
							right: '4%',
							bottom: '3%',
							containLabel: true
						},
						xAxis: {
							type: 'category',
							data: [2018,2019],
                            default: null,
						},
						yAxis: {
							type: 'value',
							data: data
						},
						series: [{
							name: '000001',
							type: 'bar',
							data: data5,
							smooth: true,
						},
							{
								name: 'admin',
								type: 'bar',
								data: data6,
								smooth: true,

							},{
								name: 'lijunwu',
								type: 'bar',
								data: data7,
								smooth: true,

							}]
					};
					// 使用刚指定的配置项和数据显示图表。
					myChart.setOption(option);
				}
			});
		}
        function  getData2() {
            $.ajax({
                type: 'get',
                url:  '${basePath!}/custom/countByMonth',
                dataType: 'json',
                data: {year:2019},
                success: function (data) {
                    console.log(data);
                    var data1 = new Array();
                    var data2 = new Array();
                    var data3 = new Array();
                    for(var i=0; i < data.length; i++){
						if(data[i].mouth == 2018-12) {
							data1.push(data[i].creator);
						}else{
							data3.push(data[i].creator);
						}
                        data2[i] = data[i].count;
                    }
                    //alert(JSON.stringify(data));
                    var ourChart = echarts.init(document.getElementById('index'));
					for(var i=0;i<data3.length;i++){
						data1.push(data3[i]);
					}
                    // 指定图表的配置项和数据
                    option = {
                        tooltip: {
                        //	trigger: 'axis',
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: {
                            type: 'category',
                            data: [1,2,3,4,5,6,7,8,9,10,11,12],
                            default: null,
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            name: '000001',
                            type: 'bar',
                            smooth: true,
							data: [5],

                        },{
							name: 'admin',
							type: 'bar',
							smooth: true,
							data: [176,4],

						},{
							name: 'lijunwu',
							type: 'bar',
							smooth: true,
							data: [86],

						}]
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    ourChart.setOption(option);
                }
            });
        }
	</script>
</body>
</html>